POV-Ray : Newsgroups : povray.general : converting rgb to spectra : Re: converting rgb to spectra Server Time
9 Aug 2024 03:21:29 EDT (-0400)
  Re: converting rgb to spectra  
From: Halbert
Date: 21 Aug 2000 21:33:00
Message: <39a1d84c@news.povray.org>
Psuedocode plagerized from Computer Graphics and Principals 2nd Edition:

procedure RGB_To_HSV( r, g b: real; var h,s v : real)
begin
    max := Maximum(r,g,b);
    min := Minimum(r,g,b);

    v := max;
if max <> 0 then
    s := (max - min)/max;
else s := 0;
if s = 0 then
   h := UNDEFINED
else
    begin
        delta := max - min;
        if r = max then
            h := (g - b)/delta;
        else if g = max then
            h := 2 + (b - r)/delta;
        else if b = max then
            h := 4 + (r - g)/delta;
        h := h* 60;
        if h < 0 then
            h := h + 360;
    end
end


This should be easily converted into a macro (assumming I haven't made too
many typing errors.)

"Ron Parker" <ron### [at] povrayorg> wrote in message
news:slr### [at] fwicom...
> On Mon, 21 Aug 2000 11:42:03 -0500, Chris Huff wrote:
> >I think it would be very useful to have rgb2hls() and hls2rgb()
> >functions, and similar ones for HSV and other color spaces. These could
> >also be useful post_process filters. The only thing stopping me from
> >writing them is a lack of knowledge of how to convert between them.
>
> The PostScript Language Reference Manual contains the necessary formulae,
> and is available in PDF format from Adobe's website.  It also might
> include some CMYK conversions, though I'm undecided as to the usefulness
> of those.
>
> --
> Ron Parker   http://www2.fwi.com/~parkerr/traces.html
> My opinions.  Mine.  Not anyone else's.
>


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.